<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑信息-教练</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/font.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/xadmin.css">
    <link rel="stylesheet" href="https://cdn.bootcdn.net/ajax/libs/Swiper/3.4.2/css/swiper.min.css">
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
    <script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/Swiper/3.4.2/js/swiper.jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/xadmin.js"></script>
</head>
<body>
<!-- 中部开始 -->
<div class="wrapper">
    <!-- 右侧主体开始 -->
    <div class="page-content">
        <div class="content">
            <!-- 右侧内容框架，更改从这里开始 -->
            <form class="layui-form" action="" method="">
                <input type="text" hidden name="coachid" value="${logUser.coachid}">
                <div class="layui-form-item">
                    <label for="L_1" class="layui-form-label">
                        登录账号
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_1" name="coachlogname" required lay-verify=""
                               autocomplete="off" value="${logUser.coachLogName}" class="layui-input" readonly>
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        登录凭证，无法修改，如需修改请联系管理员。
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_pass" class="layui-form-label">
                        <span class="x-red">*</span>密码
                    </label>
                    <div class="layui-input-inline">
                        <input type="password" id="L_pass" name="coachpassword" required="" lay-verify="pass"
                               autocomplete="off" class="layui-input" value="${logUser.coachpassword}">
                    </div>
                    <div class="layui-form-mid layui-word-aux">
                        6到16个字符
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_username" class="layui-form-label">
                        真实名字
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_username" name="coachrealname" required lay-verify="required"
                               autocomplete="off" value="${logUser.coachrealname}" class="layui-input">
                    </div>
                </div>
                <div class="layui-inline">
                    <label for="L_sex" class="layui-form-label">
                        性别
                    </label>
                    <div class="layui-input-inline" id="L_sex">
                        <c:if test="${logUser.coachsex=='男'}">
                            <input type="radio" name="coachsex" value="男" title="男" checked>
                            <input type="radio" name="coachsex" value="女" title="女">
                        </c:if>
                        <c:if test="${logUser.coachsex=='女'}">
                            <input type="radio" name="coachsex" value="男" title="男">
                            <input type="radio" name="coachsex" value="女" title="女" checked>
                        </c:if>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_cotype" class="layui-form-label">
                        锻炼方向
                    </label>
                    <div class="layui-input-inline">
                        <input type="text" id="L_cotype" name="cotype" required lay-verify="required"
                               autocomplete="off" value="${logUser.cotype}" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label for="L_username" class="layui-form-label">
                    </label>
                    <button type="button" class="layui-btn" key="set-mine" lay-filter="save" lay-submit onclick="editCo()">
                        修改
                    </button>
                    <button type="button" class="layui-btn" key="set-mine" lay-filter="save" lay-submit onclick="x_admin_close();">
                        返回
                    </button>
                </div>
            </form>
            <!-- 右侧内容框架，更改从这里结束 -->
        </div>
    </div>
    <!-- 右侧主体结束 -->
</div>
<!-- 中部结束 -->
<script>
    function editCo() {
        layer.confirm("确定修改吗",function (){
            $.ajax({
                url:"${pageContext.request.contextPath}/coach/editMess.action",
                type:"post",
                dataType:"text",
                data: {
                    coachid:$("input[name='coachid']").val(),
                    coachlogname:$("input[name='coachlogname']").val(),
                    coachpassword:$("input[name='coachpassword']").val(),
                    coachrealname:$("input[name='coachrealname']").val(),
                    coachsex:$("input[name='coachsex']:checked").val(),
                    cotype:$("#L_cotype").val()
                },
                success:function (date){
                    if ("ok"==date){
                        //关闭修改页面弹框
                        x_admin_close();
                        //刷新页面，重置session内容
                        window.top.location.href="${pageContext.request.contextPath}/coach/toOneselfPage.action";
                    }else{
                        alert("修改失败！");
                    }
                },
                error:function (){
                    console.log("error");
                }
            });
        });
    }
</script>
</body>
</html>
